﻿///<reference path="../_references.ts" />

module ScrambledEggs.Utility {
    export class General {
        public static Clone(obj) {
            return $.extend(true, {}, obj);
        }
        public static OptionBox(content: string, ...options: Option[]): void {
            var optionBox = $("#optionbox").show();
            var optionContainer = optionBox.find(".options").html("");
            optionBox.find(".content").html(content);
            $.each(options, function () {
                var option = this;
                $("<button />").html(option.Content).appendTo(optionContainer).click(function () {
                    optionBox.hide();
                    option.Action();
                });
            });
            optionBox.find(".options");
        }
        public static YesNoBox(content: string, whenYes: () => any, whenNo: () => any ): void {
            General.OptionBox(content, { Content: "Yes", Action: whenYes }, { Content: "No", Action: whenNo });
        }
        public static InfoBox(content: string, okCaption: string = "Ok", onOk?: () => any = $.noop): void {
            General.OptionBox(content, { Content: okCaption, Action: onOk });
        }
    }
    export interface Option {
        Content: string;
        Action: () => any;
    }
}